package tast3;

import java.util.ArrayList;
import java.util.List;

public class GenericMain {
	   public static <T extends Object & Comparable<T>> T max(List<T> list)
	   {                     
	      T max = list.get(0);
	      for (T a : list) {
	        if ( a.compareTo(max) > 0 ){
	         max = a; 
	      }
	    }
	      return max;
	   }
	    public static void main(String[] args) {
	        List<String>strList=new ArrayList<String>();
	        List<Integer>intList=new ArrayList<Integer>();
	        strList.add("ab");
	        strList.add("abc");
	        strList.add("abcd");
	        intList.add(1);
	        intList.add(2);
	        intList.add(3);
	        String maxStr = max(strList);
	        Integer maxInt = max(intList);
	        System.out.println("String max="+maxStr+","+"Integer max="+maxInt);
	    }
	}